/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.ImageTagDAO;
import com.sesame.domain.ImageTag;
import com.sesame.domain.TagCloud;

/**
 * @author shubeta
 * 
 */
public class ImageTagDAOImpl extends SqlMapClientDaoSupport implements
        ImageTagDAO {

    public void addImageTag(ImageTag imagetag) {
        getSqlMapClientTemplate().insert("addImageTag", imagetag);
    }

    public void deleteImageTagById(Integer id) {
        getSqlMapClientTemplate().delete("deleteImageTagById", id);
    }

    public void deleteImageTagByImageId(Integer imageId) {
        getSqlMapClientTemplate().delete("deleteImageTagByImageId", imageId);
    }

    @SuppressWarnings("unchecked")
    public List<TagCloud> getAllImageTag() {
        return (List<TagCloud>) getSqlMapClientTemplate().queryForList(
                "getAllImageTag");
    }

    public List<ImageTag> getAllImageTagByImageId(Integer imageId) {
        return (List<ImageTag>) getSqlMapClientTemplate().queryForList(
                "getAllImageTagByImageId", imageId);
    }

    public ImageTag getImageTagById(Integer id) {
        return (ImageTag) getSqlMapClientTemplate().queryForObject(
                "getImageTagById", id);
    }

    public ImageTag getImageTagByTag(String tag) {
        return (ImageTag) getSqlMapClientTemplate().queryForObject(
                "getImageTagByTag", tag);
    }

    public ImageTag getImageTagByTagAndImageId(ImageTag imageTag) {
        return (ImageTag) getSqlMapClientTemplate().queryForObject(
                "getImageTagByTagAndImageId", imageTag);
    }

    public void updateImageTag(ImageTag imagetag) {
        getSqlMapClientTemplate().update("updateImageTag", imagetag);
    }
}